package com.guzhi;

//定义一个学生类（comparable接口的实现类），具有年龄age和姓名name两个属性，并通过comparable接口提供比较规则

import org.w3c.dom.ls.LSOutput;

public class Student implements Comparable<Student>{
    private int age;
    private String name;

    public Student() {
    }

    public Student(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student o) {//重写comparable接口中的compareto方法
        return this.age - o.age;
    }
}
